package src.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class ChannelTest {
    public static void main(String[] args) {
        try {
            FileInputStream fin =new FileInputStream(new File("E:\\架构师资料\\新建文本文档.txt"));
            FileOutputStream fout =new FileOutputStream(new File("E:\\架构师资料\\copy.txt"));
            FileChannel inChannel = fin.getChannel();
            FileChannel outChannel = fout.getChannel();

            ByteBuffer buffer=ByteBuffer.allocate(6);
            inChannel.read(buffer);
            buffer.clear();
            System.out.println(new String(buffer.array()));
            //buffer.clear();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
